<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
    xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
    xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
    xmlns:fl="http://typo3.org/ns/TYPO3/CMS/Filelist/ViewHelpers">
<f:layout name="Default"/>

<f:section name="headline">
    <h1><f:translate id="search">Search</f:translate>: "{searchWord}"</h1>
</f:section>

<f:section name="content">

    <f:render partial="SearchForm" arguments="{searchWord:searchWord}" />

    <f:if condition="{files->f:count()} > 0">
        <div class="table-fit">
            <table class="table table-striped table-hover" id="typo3-filelist">
                <thead>
                <tr data-uid="0" data-l10nparent="0">
                    <th class="col-icon nowrap"></th>
                    <th class="col-path nowrap">{f:translate( key:'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c_filepath' )}</th>
                    <th class="col-title nowrap">{f:translate( key:'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c_file' )}</th>
                    <th class="col-control"></th>
                    <th class="nowrap">{f:translate( key:'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c_fileext' )}</th>
                    <th class="nowrap">{f:translate( key:'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c_tstamp' )}</th>
                    <th class="nowrap">{f:translate( key:'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c_size' )}</th>
                    <th class="nowrap">{f:translate( key:'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c_rw' )}</th>
                    <th class="nowrap">{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._REF_' )}</th>
                </tr>
                </thead>
                <tbody>
                <f:for each="{files}" as="file">
                    <tr data-uid="0" data-l10nparent="0">
                        <td class="col-icon nowrap">
                            <a class="t3js-contextmenutrigger" data-uid="{file.identifier}" data-table="sys_file" href="#">
                                <core:iconForResource resource="{file.resource}" />
                            </a>
                        </td>
                        <td class="col-path nowrap">
                            {file.path}
                        </td>
                        <td class="col-title col-responsive nowrap">
                            <f:if condition="{file.isMetadataEditable}">
                                <f:then>
                                    <a href="{be:uri.editRecord( uid:file.metadataUid, table:'sys_file_metadata', returnUrl:'{f:uri.action( action:\'search\', arguments:\'{ searchWord:\\'{searchWord->f:format.htmlentities()}\\' }\' ) -> f:format.raw()}' )}"
                                        class="filelist-file-title"
                                        title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editMetadata' )}"
                                    >
                                        {file.name}
                                    </a>
                                </f:then>
                                <f:else>
                                    {file.name}
                                </f:else>
                            </f:if>
                            <f:if condition="{file.isImage}">
                                <br>
                                <be:thumbnail image="{file.resource}" maxWidth="{thumbnail.width}" maxHeight="{thumbnail.height}" />
                            </f:if>
                        </td>
                        <td class="col-control nowrap">
                            <div class="btn-group">
                                <f:if condition="{file.isEditable}">
                                    <f:then>
                                        <a href="{fl:uri.editFileContent( file:file.resource, returnUrl:'{f:uri.action( action:\'search\', arguments:\'{ searchWord:\\'{searchWord->f:format.htmlentities()}\\' }\' ) -> f:format.raw()}' )}"
                                            class="btn btn-default filelist-file-edit"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editcontent' )}"
                                        >
                                            <core:icon identifier="actions-page-open" />
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>

                                <f:if condition="{file.IsMetadataEditable}">
                                    <f:then>
                                        <a href="{be:uri.editRecord(uid:file.metadataUid, table:'sys_file_metadata', returnUrl:'{f:uri.action( action:\'search\', arguments:\'{ searchWord:\\'{searchWord->f:format.htmlentities()}\\' }\' ) -> f:format.raw()}' )}"
                                            class="btn btn-default filelist-file-edit"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editMetadata' )}"
                                        >
                                            <core:icon identifier="actions-open" />
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>

                                <f:if condition="{file.publicUrl}">
                                    <f:then>
                                        <a href="{file.publicUrl}" target="_blank" class="btn btn-default filelist-file-view"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.view' )}"
                                        >
                                            <core:icon identifier="actions-document-view" />
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>

                                <f:if condition="{file.isReplaceable}">
                                    <f:then>
                                        <a href="{fl:uri.replaceFile( file:file.resource, returnUrl:'{f:uri.action( action:\'search\', arguments:\'{ searchWord:\\'{searchWord->f:format.htmlentities()}\\' }\' ) -> f:format.raw()}' )}"
                                            class="btn btn-default filelist-file-replace"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.replace' )}"
                                        >
                                            <core:icon identifier="actions-edit-replace" />
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>

                                <f:if condition="{file.isRenamable}">
                                    <f:then>
                                        <a href="{fl:uri.renameFile( file:file.resource, returnUrl:'{f:uri.action( action:\'search\', arguments:\'{ searchWord:\\'{searchWord->f:format.htmlentities()}\\' }\' ) -> f:format.raw()}' )}"
                                            class="btn btn-default filelist-file-rename"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.rename' )}"
                                        >
                                            <core:icon identifier="actions-edit-rename" />
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>

                                <f:if condition="{file.isReadable}">
                                    <f:then>
                                        <a href="#" class="btn btn-default filelist-file-info"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.info' )}"
                                            data-identifier="{file.identifier}"
                                        >
                                            <core:icon identifier="actions-document-info" />
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>

                                <f:if condition="{file.copyable}">
                                    <f:then>
                                        <a href="{fl:uri.copyCutFile( file:file.resource, copyOrCut: 'copy' )}"
                                            class="btn btn-default filelist-file-copy"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.copy' )}"
                                            data-redirect-url="{f:uri.action( action:'search', arguments:'{ searchWord:\'{searchWord->f:format.htmlentities()}\' }' )}"
                                        >
                                            <f:if condition="{file.selected} == 'copy'">
                                                <f:then><core:icon identifier="actions-edit-copy-release" /></f:then>
                                                <f:else><core:icon identifier="actions-edit-copy" /></f:else>
                                            </f:if>
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>
                                <f:if condition="{file.cuttable}">
                                    <f:then>
                                        <a href="{fl:uri.copyCutFile( file:file.resource, copyOrCut: 'cut' )}"
                                            class="btn btn-default filelist-file-cut"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut' )}"
                                        >
                                            <f:if condition="{file.selected} == 'cut'">
                                                <f:then><core:icon identifier="actions-edit-cut-release" /></f:then>
                                                <f:else><core:icon identifier="actions-edit-cut" /></f:else>
                                            </f:if>
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>


                                <f:if condition="{file.isDeletable}">
                                    <f:then>
                                        <a href="#" class="btn btn-default t3js-filelist-delete"
                                            title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.delete' )}"
                                            data-identifier="{file.identifier}"
                                            data-title="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.delete' )}"
                                            data-content="{f:translate( key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.delete', arguments: '{0:file.name}' )}"
                                            data-check="{f:if(condition:settings.jsConfirmationDelete, then:'1', else:'0')}"
                                            data-delete-url="{deleteUrl}"
                                            data-delete-type="delete_file"
                                            data-redirect-url="{f:uri.action( action:'search', arguments:'{ searchWord:\'{searchWord->f:format.htmlentities()}\' }' )}"
                                        >
                                            <core:icon identifier="actions-edit-delete" />
                                        </a>
                                    </f:then>
                                    <f:else>
                                        <span class="btn btn-default disabled"><core:icon identifier="empty-empty" /></span>
                                    </f:else>
                                </f:if>
                            </div>
                        </td>
                        <td class="nowrap">{file.extension}</td>
                        <td class="nowrap">{file.lastModified}</td>
                        <td class="nowrap">{file.size}</td>
                        <td class="nowrap">
                            <f:if condition="{file.isReadable}"><strong class="text-danger">{f:translate( key:'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:read' )}</strong></f:if><f:if condition="{file.isWritable}"><strong class="text-danger">{f:translate( key:'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:write' )}</strong></f:if>
                        </td>
                        <td class="nowrap">
                            <f:if condition="{file.referenceCount} > 0">
                                <f:then>
                                    <a href="#" class="filelist-file-references" data-identifier="{file.identifier}" title="{f:translate( key:'LLL:EXT:backend/Resources/Private/Language/locallang.xlf:show_references' )} ({file.referenceCount})">{file.referenceCount}</a>
                                </f:then>
                                <f:else>
                                    -
                                </f:else>
                            </f:if>
                        </td>
                    </tr>
                </f:for>
                </tbody>
            </table>
        </div>
    </f:if>

    <f:render partial="ListOptions" arguments="{checkboxes:checkboxes}" />
    <f:render partial="ClipBoard" arguments="{showClipBoard:showClipBoard,clipBoardHtml:clipBoardHtml}" />
</f:section>
</html>
